

package com.maoshi.shop.service;

import cn.hutool.core.date.DateTime;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.maoshi.shop.bean.app.dto.OrderCountData;
import com.maoshi.shop.bean.app.dto.ShopCartOrderMergerDto;
import com.maoshi.shop.bean.model.Order;
import com.maoshi.shop.bean.model.OrderItem;
import com.maoshi.shop.bean.param.OrderParam;
import com.maoshi.shop.bean.param.OrderPayParam;

import javax.servlet.http.HttpServletResponse;
import java.util.Date;
import java.util.List;

/**
 * @author lgh on 2018/09/15.
 */
public interface OrderService extends IService<Order> {


    Order getOrderByOrderNumber(String orderNumber);

    /**
     * 根据订单号和用户id获取订单
     * @param orderNumber
     * @param userId
     * @return
     */
    Order getOrderByOrderNumberAndUserId(String orderNumber,String userId, boolean valid);

    /**
     * 根据店铺id获取支付数据
     * @param shopId
     */
    OrderPayParam getPayUserCountByshopId(Long shopId, Date startTime, Date endTime);

    /**
     * 根据时间和店铺id获取分段时间数据
     */
    OrderPayParam getActualTotalByHour(Long shopId, Date startTime, Date endTime);

    /**
     * 根据天数和店铺id获取分段时间数据
     */
    List<OrderPayParam> getActualTotalByDay(Long shopId, Date startTime, Date endTime);

    /**
     * 根据店铺id和订单号获取订单
     * @param orderNumber
     * @param shopId
     * @return
     */
    Order getOrderByOrderNumberAndShopId(String orderNumber,Long shopId, boolean valid);


    ShopCartOrderMergerDto putConfirmOrderCache(String userId, ShopCartOrderMergerDto shopCartOrderMergerDto);

    ShopCartOrderMergerDto getConfirmOrderCache(String userId);

    void removeConfirmOrderCache(String userId);


    List<Order> submit(String userId, ShopCartOrderMergerDto mergerOrder);

    void delivery(Order order);

    List<Order> listUnRefundOrderAndOrderItems(Integer orderStatus, DateTime lessThanUpdateTime);

    void cancelOrders(List<Order> orders);

    void receiptOrder(List<Order> orders);

//    List<Order> listOrdersDetialByOrder(Order order, Date startTime, Date endTime);

    IPage<Order> pageOrdersDetialByOrderParam(Page<Order> page, OrderParam orderParam);

    void deleteOrders(List<Order> orders);

    OrderCountData getOrderCount(String userId);

    double sumTotalDistributionAmountByOrderItem(List<OrderItem> orderItems);

    void changeAmount(Order order);

    void soldExcel(OrderParam orderParam, HttpServletResponse response);

    List<Order> getOrderPayInfoByOrderNumber(List<String> orderNumberList);
}
